Publication of Japanese Unexamined Patent Application No. JP-A-2004-90316 describes a carriage of a related art image forming apparatus. The carriage is equipped with an edge detection sensor for detecting an edge of a recording medium. At the time of commencement of printing, the edge detection sensor detects positions of both edges of the recording medium by means of moving the carriage in the main scan direction. The width of the recording medium is computed from a result of the detection. In accordance with the positions of both edges of the recording medium, the carriage is moved, and the recording head subjects the recording medium to printing.
During the printing operation, the edge detection sensor detects one edge of the recording medium; computes the other edge from the width of the recording medium; re-detects positions of both edges of the recording medium; and moves the carriage in accordance with the re-detected positions of both edges. Thus, even when the recording medium is conveyed while being slightly misaligned, the related art image forming apparatus can accurately print an image, and the image is prevented from being printed on the recording medium in a skewed manner.